<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Free CSS Navigation Menu Designs 2 at exploding-boy.com</title>
<link rel="stylesheet" type="text/css" media="screen" href="css/codegen.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
</head>
<body>
<div class="navBc">Home > Template > 코드생성기</div>
	<div id="master">
		<div id="master1">
			<label for="systemgubun">시스템구분</label>
			<select id="systemgubun">
				<option value="1">공통</option>
				<option value="2">학사</option>
				<option value="3">행정</option>
				<option value="4">연구</option>
				<option value="5">부속</option>
			</select>
			<label for="unitUpmuGubun">단위업무구분</label><input type="text" id="unitUpmuGubun" />
			<label for="smallUnitUpmuGubun">소단위업무구분</label><input type="text" id="smallUnitUpmuGubun"/>
		</div>
		<div id="master2">
			<label for="largeClassUpmuName">대분류업무명</label><input type="text" id="largeClassUpmuName"/><button id="btnAction">Action생성</button>
			<label for="bizname">업무명</label><input type="text" id="bizname" /><button id="btnEtc">기타생성</button>
			<label for="owner">작성자</label><input type="text" id="owner" />
		</div>
		<div id="master3">
			<label for="actionclassname">Action클래스명</label><input type="text" id="actionclassname" />
			<label for="serviceclassname">서비스클래스명</label><input type="text" id="serviceclassname" />
			<label for="modelclassname">모델클래스명</label><input type="text" id="modelclassname" />
			<label for="sqlclassname">SQL클래스명</label><input type="text" id="sqlclassname" />
		</div>
		<div id="master4">
			<label for="miplatform">Miplatform</label><input type="text" id="miplatform" />
			<label for="jqueryform">jQuery Form</label><input type="text" id="jqueryform" />
		</div>
	</div>
	<div>
			<label for="">오라클 User 테이블 명(모델생성시 필요)</label>
			<label for="schemaname">스키마명</label>
			<select id="schemaname">
				<option value="1">공통</option>
				<option value="2">학사</option>
				<option value="3">행정</option>
				<option value="4">연구</option>
				<option value="5">부속</option>
			</select>
			<label for="">COM 계정에 Grant를 줘야 조회가 됩니다</label>
			<button id="query">조회</button>
	</div>
	<div>
		<div class="tableList"><table id="tableList"></table></div>
		<div class="columnInfo"><table id="columnInfo"></table></div>
	</div>

	<div id="tabs8">
		<ul>
			<li id="current"><a href="#"><span>Groovy</span></a></li>
			<li><a href="#"><span>Model</span></a></li>
			<li><a href="#"><span>Service</span></a></li>
			<li><a href="#"><span>Action</span></a></li>
			<li><a href="#"><span>Miplaform</span></a></li>
			<li><a href="#"><span>jQuery</span></a></li>
		</ul>
	</div>
	<div><button id="btnTemplate">Action템플릿조회</button></div>
	<div><textarea id="srcTemplate" rows="20" cols="100"></textarea></div>

<script type="text/javascript">
	var url;
	var unitUpmuGubun;
	var smallUnitUpmuGubun;
	var largeClassUpmuName;

	// Action생성 버튼 클릭
	$("#btnAction").click(function(){
		unitUpmuGubun = $("#unitUpmuGubun").val();
		smallUnitUpmuGubun = $("#smallUnitUpmuGubun").val();
		largeClassUpmuName = $("#largeClassUpmuName").val();

		if ($("#master4").find('.msg').length > 0){
			$("#master4").children().remove('.msg');
		}

		if (unitUpmuGubun==null || unitUpmuGubun.replace(/^\s*/,'') == "") {
			if ($("#master4").find('.msg').length == 0) {
				$("#master4").append('<label class="msg">단위업무구분을 입력해주세요!!!</label>');
			}
			return;
		}

		if (smallUnitUpmuGubun==null || smallUnitUpmuGubun.replace(/^\s*/,'') == "") {
			if ($("#master4").find('.msg').length == 0) {
				$("#master4").append('<label class="msg">소단위업무구분을 입력해주세요!!!</label>');
			}
			return;
		}

		if (largeClassUpmuName==null || largeClassUpmuName.replace(/^\s*/,'') == "") {
			if ($("#master4").find('.msg').length == 0) {
				$("#master4").append('<label class="msg">대분류업무명을 입력해주세요!!!</label>');
			}
			return;
		}

		if ($("#master4").find('.msg').length > 0){
			$("#master4").children().remove('.msg');
		}

		url='http://localhost:8080/com/com/comm/tmpl/getActionNm.action?unitUpmuNm=업무';
		//url='actionbutton.json';
		$.ajax({
			type: "get",
			url: url,
			datatype: "json",
			contentType: "application/extJs+sua; charset=utf-8",
			success: function(json){
				$("#master4").append('<label class="msg">OK!!!</label>');
				if(json.DS_ACTION == null) {
					alert("단위업무명이 존재하지 않습니다");
				} else {
					$.each(json.DS_ACTION,function(i,data){
						$("#actionclassname").val(data.actionClass);
					});
				}
			},
			error: function(data, status, err) {
				console.log("error forward : "+data);
				alert("통신 오류입니다. 시스템관리자에게 문의하시기 바랍니다.");
			}
		});
	});

	// 조회버튼 클릭
	$("#query").click(function(){
		$("#tableList").html("");
		$("#columnInfo").html("");

		$("#tableList").append(
					'<tr>'+
						'<th class="no">순번</th>'+
						'<th class="tablename">테이블명</th>'+
						'<th class="remarks">테이블주석</th>'+
					'</tr>'
		);

		url='http://localhost:8080/com/com/comm/tmpl/getTableJeongbo.action?skima=COM';
		//url='tablelist.json';
		$.ajax({
			type: "get",
			url: url,
			datatype: "json",
			contentType: "application/extJs+sua; charset=utf-8",
			success: function(json){
				if(json.DS_TMPL010 == null) {
				   $("#tableList").append(
					   '<tr>'+
					   '<td colspan="8">검색된 결과가 없습니다.</td>'+
				   	'</tr>');
				} else {
					$.each(json.DS_TMPL010,function(i,data){
						$('<tr>').append($('<td>').addClass('no').html(i))
								 .append($('<td>').addClass('tablename').html(data.tableName))
								 .append($('<td>').addClass('remarks').html(data.comments))
								 .bind("click",function(){clickedTableList($(this));})
								 .appendTo("#tableList");
//						$("#tableList").append(
//							'<tr>'+
//								'<td class="no">'+i+'</td>'+
//								'<td class="tablename">'+data.tableName+'</td>'+
//								'<td class="remarks">'+data.comments+'</td>'+
//							'</tr>');
					});

				}
			},
			error: function(data, status, err) {
				console.log("error forward : "+data);
				alert("통신 오류입니다. 시스템관리자에게 문의하시기 바랍니다.");
			}
		});
	});

	// 테이블 라인 클릭
	function clickedTableList($obj) {
		var tablename = $obj.find("td.tablename").text();
 		$("#columnInfo").html("");
		$("#columnInfo").append(
					'<tr>'+
						'<th class="chk"><input class="chk" type="checkbox"/></th>'+
						'<th class="columnName">컬럼ID</th>'+
						'<th class="tablename">테이블명</th>'+
						'<th class="comments">컬럼주석</th>'+
						'<th class="dataLength">Length</th>'+
						'<th class="constraintType">PK</th>'+
						'<th class="dataDefault">Data Default</th>'+
					'</tr>'
		);
		url='http://localhost:8080/com/com/comm/tmpl/getColumnJeongbo.action?skima=COM&tableNm='+tablename;
		//url='columninfo.json';
		//chk=0, columnId=1, owner=COM, tableName=PROGMA01TT, columnName=PROGRAM_ID,
		//comments=프로그램ID, dataLength=8, constraintType=P, dataDefault=null
		$.ajax({
			type: "get",
			url: url,
			datatype: "json",
			contentType: "application/extJs+sua; charset=utf-8",
			success: function(json){
				if(json.DS_TMPL011 == null) {
				   $("#columnInfo").append(
					   '<tr>'+
					   '<td colspan="8">검색된 결과가 없습니다.</td>'+
				   	'</tr>');
				} else {
					$.each(json.DS_TMPL011,function(i,data){
						$("#columnInfo").append(
							'<tr>'+
								'<td class="chk"><input class="chk" type="checkbox"/></td>'+
								'<td class="columnId">'+data.columnName+'</td>'+
								'<td class="tablename">'+data.tableName+'</td>'+
								'<td class="comments">'+data.comments+'</td>'+
								'<td class="dataLength">'+data.dataLength+'</td>'+
								'<td class="constraintType">'+data.constraintType+'</td>'+
								'<td class="dataDefault">'+data.dataDefault+'</td>'+
							'</tr>');
					});
				}
			},
			error: function(data, status, err) {
				console.log("error forward : "+data);
				alert("통신 오류입니다. 시스템관리자에게 문의하시기 바랍니다.");
			}

		});

/*
		$("#columnInfo").jqGrid({
			url: url,
			datatype: "json",
			contentType: "application/extJs+sua; charset=utf-8",
			colNames:['chk','컬럼ID','테이블명', '컬럼주석','Length','PK','Data Default'],
			colModel:[
				{name:'chk',index:'chk'},
				{name:'columnId',index:'columnId'},
				{name:'tableName',index:'tableName', align:"left"},
				{name:'comments',index:'comments', align:"left"},
				{name:'dataLength', index:'dataLength', align:"center"},
				{name:'constraintType',index:'constraintType', align:"center"},
				{name:'dataDefault',index:'dataDefault', sortable:false}
			],
			sortname: 'id',
			viewrecords: true,
			sortorder: "desc"
		});
*/
	};

	// Action 템플릿조회 버튼 클릭
	$("#btnTemplate").click(function(){
		var src = "Good!!!";
		$("textarea#srcTemplate").val(src);
	});
	
</script>
</body>
</html>